<?php
class Block_Admin_Abiturient_View_Item
    extends Block_Core_Form_Abstract
{
    protected $_formName = 'abiturient_view_form';

    protected $_formId = 'abiturient_view_form';

    protected $_jsName = 'abiturient_view';

    protected function _prepareForm()
    {
        $collection = new Model_Eav_Resource_Attribute_Collection();
        $collection->load();
        $items = $collection->getItems();

        $fieldset = new Block_Core_Form_Fieldset_Abstract();
        $fieldset->setData(array('label'=>'Abiturient Informaton','title'=>'Abiturient Informaton','view'=>'open'));

        $fieldset->addField(array(
            'type' => 'hidden',
            'name' => 'abiturient[id]',
            'value'=> $this->getEntityId(),
        ));

        $_helper = new Helper_Core_Form_Items();

        foreach ($_helper->getFormItems($items,$this,'abiturient') as $_item) {
            $fieldset->addField($_item);
        }

        $this->addFieldset($fieldset);

        return parent::_prepareForm();
    }

    public function _prepareData()
    {
        /* @var $controller Zend_Controller_Front */
        $controller = Zend_Controller_Front::getInstance();
        $item = $controller->getRequest()->getParam('item',null);

        if($item) {
            $model = new Model_Abiturient_Item();
            $model->load($item);

            foreach ($model->getData() as $key=>$value) {
                $this->setData($key,$value);
            }
        }

        return parent::_prepareData();
    }
}
